feat: introduce otp login flow for us region#1373
Conversation
|
@cdnninja This is the pared PR that utilizes the merged API changes. Can I get it reviewed too? |
|
This will need a manifest bump for the api. I am thinking we do that first and release, give it a few days and merge this. Purely to confirm stability for other regions. |
Is the manifest bump manual or automatic? |
|
The api version in manifest needs to be manually bumped. The release of the integration and its own version is automatic. |
|
@cdnninja I have tested this branch with |
|
I am thinking separate PR so that we can release the API with all those changes and confirm nothing breaks in the process. My understanding is it should function with the current integration for all regions. Are you able to create a PR for that? |
|
@cdnninja, I can't test this because the US version doesn't log in at all without these changes. So it is definitely in a broken state without this PR. If you can test EU login workflow or CA that would be great. |
|
I can't. I don't own one of these cars anymore. If you are around the next day let's add the api to this PR. My ask is to keep an eye out for new regression on GitHub if a fix is needed. |
1d6be5f to
f5da5a2
Compare
for more information, see https://pre-commit.ci
|
@cdnninja Done. I am confident about the US side, and I will keep an eye out for new issues in other regions for the next week. |
Summary Implements OTP (2FA) login flow for USA region and persists both rmtoken (remember token) and device_id to prevent repeated OTP prompts across Home Assistant restarts. Keeps non-USA regions unchanged. Adds minimal type annotations for Vehicle in a few entity modules (non-functional). Functional changes Config flow (config_flow.py) Adds OTP steps for USA region: send_otp and input_otp_code Stores rmtoken and device_id in the created entry’s data Reuses stored rmtoken/device_id to avoid OTP on subsequent logins Coordinator (coordinator.py) Pre-seeds token with stored rmtoken/device_id before authentication Persists updated rmtoken/device_id back to ConfigEntry after successful refresh Uses a non-interactive OTP handler during runtime updates Constants (const.py) Adds CONF_RMTOKEN and CONF_DEVICE_ID for persistence Translations (translations/en.json and localized variants if present) Adds strings for OTP flow UI Compatibility and migration USA region: Existing entries are auto-updated; the first login may prompt for OTP, after which rmtoken/device_id are saved and reused Other regions: No change No user action required; if authentication gets stuck, removing and re-adding the integration will re-run the new flow Security and privacy rmtoken and device_id are stored in the integration’s ConfigEntry data (Home Assistant storage); treat this as sensitive material Deleting the integration removes these values Testing and validation Verified OTP flow (send and validate), successful session establishment, and reuse of rmtoken/device_id across restarts for USA Confirmed DataUpdateCoordinator refresh works without OTP prompts after initial verification Compiled all modified modules with py_compile successfully Notes Requires hyundai_kia_connect_api library version that implements OTP and token/device_id support for USA No breaking changes anticipated for non-USA users How to test Configure the integration for USA Complete OTP once when prompted Restart Home Assistant and verify no additional OTP prompt appears, and data updates continue normally --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Summary
Implements OTP (2FA) login flow for USA region and persists both rmtoken (remember token) and device_id to prevent repeated OTP prompts across Home Assistant restarts.
Keeps non-USA regions unchanged.
Adds minimal type annotations for Vehicle in a few entity modules (non-functional).
Functional changes
Config flow (config_flow.py)
Adds OTP steps for USA region: send_otp and input_otp_code
Stores rmtoken and device_id in the created entry’s data
Reuses stored rmtoken/device_id to avoid OTP on subsequent logins
Coordinator (coordinator.py)
Pre-seeds token with stored rmtoken/device_id before authentication
Persists updated rmtoken/device_id back to ConfigEntry after successful refresh
Uses a non-interactive OTP handler during runtime updates
Constants (const.py)
Adds CONF_RMTOKEN and CONF_DEVICE_ID for persistence
Translations (translations/en.json and localized variants if present)
Adds strings for OTP flow UI
Compatibility and migration
USA region: Existing entries are auto-updated; the first login may prompt for OTP, after which rmtoken/device_id are saved and reused
Other regions: No change
No user action required; if authentication gets stuck, removing and re-adding the integration will re-run the new flow
Security and privacy
rmtoken and device_id are stored in the integration’s ConfigEntry data (Home Assistant storage); treat this as sensitive material
Deleting the integration removes these values
Testing and validation
Verified OTP flow (send and validate), successful session establishment, and reuse of rmtoken/device_id across restarts for USA
Confirmed DataUpdateCoordinator refresh works without OTP prompts after initial verification
Compiled all modified modules with py_compile successfully
Notes
Requires hyundai_kia_connect_api library version that implements OTP and token/device_id support for USA
No breaking changes anticipated for non-USA users
How to test
Configure the integration for USA
Complete OTP once when prompted
Restart Home Assistant and verify no additional OTP prompt appears, and data updates continue normally